function planet3D(name, radius, orbital_radius, orbital_period){
	
	var that = this;
	
	this.name = name || 'earth';
	
	this.radius = Math.log(1 + radius) ||  Math.log(2);
	this.orbital_radius = Math.log(1 + orbital_radius) * 20 || 0;
	this.rotation_speed = 0.07;
	this.orbital_period = orbital_period || 1;
	
	// The planet object
	this.texture_url = '/static/img/texture/' + this.name + '_map.jpg';
	this.geometry = new THREE.SphereGeometry(this.radius, 20, 20);
	this.texture = THREE.ImageUtils.loadTexture(this.texture_url);
	this.material = new THREE.MeshBasicMaterial({map: this.texture, overdraw: true});
	this.mesh = new THREE.Mesh(this.geometry, this.material);
	this.mesh.rotation.x = Math.PI/2
	
	// The animate function
	this.animate = function(){
		var date = new Date(),
			alpha = Math.PI * (date.getTime() % (10000 * that.orbital_period)) / (5000 * that.orbital_period);
		
		that.mesh.rotation.y += that.rotation_speed;
		that.mesh.position.x = that.orbital_radius * 1.1 * Math.cos(alpha);
		that.mesh.position.y = that.orbital_radius * 0.9 * Math.sin(alpha);
	}
	
	// The orbit
	var curve = new THREE.EllipseCurve(0,  0,
									   this.orbital_radius* 1.1 , this.orbital_radius * 0.9,
									   0,  2 * Math.PI,
									   false);
	var path = new THREE.Path(curve.getPoints(50));
	var orbit_geometry = path.createPointsGeometry(50);
	var orbit_material = new THREE.LineBasicMaterial({color: 0x333333});
	this.orbit = new THREE.Line(orbit_geometry, orbit_material);
};

function displayPlanet(view_context){
	
	var planet_3D = new planet3D();
	
	view_context.reset();
	view_context.camera.position = new THREE.Vector3(0, 0, 3)
	view_context.animateFunctions.push(planet_3D.animate)
	view_context.scene.add(planet_3D.mesh);

}
